/**
 * Created by XianTao on 2016/4/26
 * <p/>
 * Copyright (c) 2015-2015
 * Apache License
 * Version 2.0, January 2004
 * http://www.apache.org/licenses/
 */
package org.lego.biz.wechat.lechuan.mobile.api.handler;

import org.lego.wechat.base.msg.in.InMsg;
import org.lego.wechat.base.msg.in.event.InFollowEvent;
import org.lego.wechat.base.msg.out.OutMsg;
import org.lego.wechat.base.msg.out.OutTextMsg;
import org.lego.wechat.portal.service.AbstractWechatHandler;
import org.lego.wechat.portal.service.WechatHandler;
import org.springframework.stereotype.Service;

/**
 * 关注事件处理器
 */
@Service
public class FollowSubscribeHandler extends AbstractWechatHandler {
    public boolean isMatch(InMsg inMsg) {
        if (inMsg instanceof InFollowEvent) {
            InFollowEvent inFollowEvent = (InFollowEvent) inMsg;
            return InFollowEvent.EVENT_INFOLLOW_SUBSCRIBE.equals(inFollowEvent.getEvent());
        }
        return false;
    }

    public OutMsg process(InMsg inMsg) {
        OutTextMsg outTextMsg = new OutTextMsg(inMsg);
        outTextMsg.setContent("嗨，亲，终于等到您！\n" +
                "嗨乐传：最值得关注的微信公众平台。每日为您推送鲜活信息，麻辣资讯，洞察时事，解读经济，深度调查，成就您的领袖眼光和观察视野。\n" +
                "欢迎多交流，和嗨乐传一起打造最有料、最有乐、最有味道的读者俱乐部。\n");
        return outTextMsg;
    }

    public WechatHandler getMyself() {
        return this;
    }
}